<?php
namespace app\index\controller;
use think\Controller;
use think\Db;

class Index extends Controller
{
	public function index()
    {
        $this->redirect('Makescore/matching');
    }

    /**
     * 赛事报名
     */
    public function sign()
    {
        return view();
    }

    public function handleSign()
    {
        $data = input();
        $rel = Db::name('sign')->where('song',$data['song'])->where('player',$data['player'])->where('grp',$data['grp'])->find();
        if($rel) {
            return ['flag'=>1];
        }
        $tmp['signid'] = build_order_no();
        $tmp['song'] = $data['song'];
        $tmp['grp'] = $data['grp'];
        $tmp['player'] = $data['player'];
        $tmp['phone'] = $data['phone'];
        $id = Db::name('sign')->insertGetId($tmp);
        $item['id'] = $id;
        $item['player'] = $tmp['player'];
        return json(['flag'=>0,'data'=>$item]);
    }

    /**
     * 报名成功
     */
    public function applywin()
    {
        return view();
    }
}